<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <title>百度在线考试平台--试卷管理列表</title>
    <link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css">
    <script src="/bootstrap/js/jquery.min.js"></script>
    <script src="/bootstrap/js/bootstrap.min.js"></script>
    <style>
        table {
            border-collapse: collapse;
            width: 100%;
        }

        th, td {
            padding: 8px;
            text-align: left;
            border-bottom: 1px solid #ddd;
        }
    </style>
    <script>
        function gotoPage(p){
            location.href="/papers?currtPage="+p;
        }
        function add(){
            location.href="/papers/showRepo";
        }
    </script>
</head>
<body>
<div class="container">
    <div class="panel panel-success">
        <div class="panel-heading panel-title text-center">
            <h1>百度在线考试平台--试卷管理列表</h1>
        </div>
        <div class="panel-body">
            <form action="/papers" class="form-horizontal form-inline">
                <input type="text" class="form-control" name="title" value="${param.title}" placeholder="试卷名称..." maxlength="20"/>
                <button type="submit" class="btn btn-primary glyphicon glyphicon-search" >搜索</button>
            </form>
            <table>
                <tr>
                    <th>ID</th>
                    <th>试卷名称</th>
                    <th>单选题数量</th>
                    <th>单选题分数</th>
                    <th>多选题数量</th>
                    <th>多选题分数</th>
                    <th>判断题数量</th>
                    <th>判断题分数</th>
                    <th>创建人</th>
                    <th>创建时间</th>
                    <th>操作</th>
                    <th><button onclick="add()">添加</button></th>
                </tr>
                <%-- 使用JSP标签循环遍历并渲染Paper数据 --%>
                <c:forEach var="paper" items="${page.list}">
                    <tr>
                        <td>${paper.id}</td>
                        <td>${paper.title}</td>
                        <td>${paper.radioCount}</td>
                        <td>${paper.radioScore}</td>
                        <td>${paper.checkCount}</td>
                        <td>${paper.checkScore}</td>
                        <td>${paper.judgeCount}</td>
                        <td>${paper.judgeScore}</td>
                        <td>${paper.userId}</td>
                        <td><fmt:formatDate value="${paper.createTime}" pattern="yyyy年MM月dd日"/></td>
                        <td>
                            <a href="/papers/delete/${paper.id}" onclick="" class="btn btn-primary">删除试卷</a>
                            <a href="/papers/view/${paper.id}" class="btn btn-info">查看试卷</a>
                        </td>
                    </tr>
                </c:forEach>

                <tr>
                    <td colspan="8" class="text-center">
                        <ul class="pagination ">
                            <c:if test="${page.totalCount>0}">
                                总${page.totalCount}条  每页${page.pageLimit}条
                                <%-- <c:forEach begin="1" step="1" end="${page.totalPage}" var="p">
                                     <li><a href="javascript:gotoPage(${p})">${p}</a></li>
                                 </c:forEach>--%>
                                <a href="${pageContext.request.contextPath}/${page.url}?currtPage=${page.currtPage-1}${page.params}">上一页</a>  <a href="${pageContext.request.contextPath}/${page.url}?currtPage=${page.currtPage+1}${page.params}">下一页</a>
                            </c:if>
                            <c:if test="${page.totalCount<=0}">
                                对不起，暂无数据
                            </c:if>

                        </ul>
                    </td>
                </tr>

            </table>
        </div>
        <div class="panel-footer text-right">
            百度在线考试平台
        </div>
    </div>
</div>
</body>
</html>
